/*
 * @Description: 用户新建、编辑操作hooks
 * @Author: chenju
 * @Date: 2022-12-06 16:02:02
 * @LastEditors: chenju
 * @LastEditTime: 2022-12-07 11:28:51
 */
import { ref } from 'vue';
import { getUserRoleListGroupBy } from '@/apis/system/user';
import type { GetUserRoleListGroupByResult } from '@/apis/system/model/userModel';

export const useUserBusinessRole = () => {
  // 用户业务角色列表
  const enterpriseRoleList = ref<GetUserRoleListGroupByResult[]>([]);

  // 获取用户业务角色列表
  async function getRoleList() {
    try {
      const res = await getUserRoleListGroupBy();
      enterpriseRoleList.value = res;
      return Promise.resolve(true);
    } catch (error) {
      console.log('error', error);
      return Promise.resolve(false);
    }
  }
  return {
    enterpriseRoleList,
    getRoleList
  };
};
